package com.guang.dubbo.shoulu.v1.framework.http;

import com.guang.dubbo.shoulu.v1.framework.Invocation;
import com.guang.dubbo.shoulu.v1.framework.Invoker;
import com.guang.dubbo.shoulu.v1.framework.URL;
import com.guang.dubbo.shoulu.v1.framework.web.HttpClient;
import lombok.AllArgsConstructor;

import java.io.IOException;

/**
 * http需要进行实现的invoker
 */
@AllArgsConstructor
public class HttpInvoker implements Invoker {

    private URL url;



    @Override
    public String invoke(Invocation invocation) {
        try {
            return HttpClient.send(url.getHostname(), url.getPort(), invocation);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
